KVERSION = 2.6.38-8-generic
KBUILD = /lib/modules/$(shell uname -r)/build
TARGET = tutorfs
obj-m += $(TARGET).o
$(TARGET)-objs := src/inode.o src/mysocket.o src/file.o src/util.o src/protocol.o

all: modules install clean
	@echo --- succeeded!!! ---

modules:
	make -C $(KBUILD) M=$(PWD) modules

clean:
	make -C $(KBUILD) M=$(PWD) clean

install:
	sudo rmmod $(TARGET); \
	sudo mkdir -p /lib/modules/$(KVERSION)/kernel/drivers/$(TARGET)
	sudo cp $(TARGET).ko /lib/modules/$(KVERSION)/kernel/drivers/$(TARGET)
	sudo depmod -a
	sudo modprobe $(TARGET)

uninstall:
	sudo rmmod $(TARGET)